import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: null,
    // 数据缓存
    cache: {
      menus: null,
      testMenu: {
        top: 0,
        left: 0
      }
    },

    // 第一个下拉菜单栏
    options: [{
      value: '选项1',
      label: '大班课'
    },
    {
      value: '选项2',
      label: '小班课'
    },
    {
      value: '选项3',
      label: '点播课'
    },
    {
      value: '选项4',
      label: '面授课'
    },
    {
      value: '选项5',
      label: '音频课'
    },

    {
      value: '选项6',
      label: '图文课'
    }],
    // 联动下拉栏
    list: [{
      value: 'zhinan',
      label: '指南',
      children: [{
        value: 'shejiyuanze',
        label: '设计原则'
      },
      {
        value: 'yizhi',
        label: '一致'
      }, {
        value: 'fankui',
        label: '反馈'
      }, {
        value: 'xiaolv',
        label: '效率'
      }, {
        value: 'kekong',
        label: '可控'
      }]
    },
    {
      value: 'zhujian',
      label: '组件',
      children: [{
        value: 'basic',
        label: 'Basic'
      },
      {
        value: 'layout',
        label: 'Layout 布局'
      }, {
        value: 'color',
        label: 'Color 色彩'
      }, {
        value: 'typography',
        label: 'Typography 字体'
      }, {
        value: 'icon',
        label: 'Icon 图标'
      },
      {
        value: 'button',
        label: 'Button 按钮'
      }]
    },
    {
      value: 'ziyuan',
      label: '资源',
      children: [{
        value: 'axure',
        label: 'Axure Components'
      }, {
        value: 'sketch',
        label: 'Sketch Templates'
      }, {
        value: 'jiaohu',
        label: '组件交互文档'
      }]
    },
    {
      value: 'others',
      label: 'Others',
      children: [{
        value: 'dialog',
        label: 'Dialog 对话框'
      }, {
        value: 'tooltip',
        label: 'Tooltip 文字提示'
      }, {
        value: 'popover',
        label: 'Popover 弹出框'
      }, {
        value: 'card',
        label: 'Card 卡片'
      }, {
        value: 'carousel',
        label: 'Carousel 走马灯'
      }, {
        value: 'collapse',
        label: 'Collapse 折叠面板'
      }]

    },
    {
      value: 'navigation',
      label: 'Navigation',
      children: [{
        value: 'menu',
        label: 'NavMenu 导航菜单'
      }, {
        value: 'tabs',
        label: 'Tabs 标签页'
      }, {
        value: 'breadcrumb',
        label: 'Breadcrumb 面包屑'
      }, {
        value: 'dropdown',
        label: 'Dropdown 下拉菜单'
      }, {
        value: 'steps',
        label: 'Steps 步骤条'
      }]
    }
    ]
  },

  mutations: {
    set_user(state, data) {
      state.user = data
    },
    set_menu_cache(state, data) {
      state.cache.menus = data
    },
    add(state, formName) {
      state.CouponManage.push({
        title: formName.name,
        fanwei: formName.type,
        youxiaoqi: '一年',
        ling: '13/111',
        zhuang: formName.region,
        leixing: formName.resource
      })
    },
    setTestMenuTop(state, data) {
      state.cache.testMenu.top = data
    },
    setTestMenuLeft(state, data) {
      state.cache.testMenu.left = data
    }
  },
  actions: {},
  modules: {},
  plugins: [createPersistedState({
    storage: sessionStorage,
    paths: [
      'user.avatar',
      'user.nickname',
      'user.remember_token',
      'cache'
    ]
  })]
})
